﻿using SQLite;
using System;
using System.ComponentModel;

namespace OneDark.Update
{
    public enum RepoStatus
    {
        Normal,             // 正常
        Conflict,           // 冲突
        Conflict_Update,    // 更新冲突
        Repeat,             // 重复
        Unversioned,        // 没有远端仓库
        RemotedDeleted      //远端仓库被删除
    }

    public enum RepoPullStatus
    {
        None,
        PullStart,
        Conflict,
        PullFinished
    }

    public enum RepoSource
    {
        None,
        GitHub,
        Gitee,
        Oschina
    }

    public class GitProperty : INotifyPropertyChanged
    {
        /// <summary>
        /// 工程路径
        /// </summary>
        [PrimaryKey]
        public string Path { set; get; }

        /// <summary>
        /// 仓库Url
        /// </summary>
        //[Indexed("gp_pk", 1)]
        public string Url { set; get; }

        /// <summary>
        /// 仓库分支
        /// </summary>
        //[Indexed("gp_pk", 2)]
        public string Branch { set; get; }

        /// <summary>
        /// 勾选
        /// </summary>
        [SQLite.Ignore]
        public bool Check { set; get; }

        /// <summary>
        /// 项目名称
        /// </summary>
        public string Project { set; get; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpTime { set; get; }

        /// <summary>
        /// 更新进度
        /// </summary>
        [SQLite.Ignore]
        public int Progress { set; get; }

        /// <summary>
        /// Putty Key路径
        /// </summary>
        public string PuttyKeyFile { set; get; }

        /// <summary>
        /// 文件夹大小
        /// </summary>
        public int DicSize { set; get; }

        /// <summary>
        /// 上次提交时间
        /// </summary>
        public DateTime LastCommit { set; get; }

        /// <summary>
        /// 上次提交时间
        /// </summary>
        public DateTime LastPullTime { set; get; }

        /// <summary>
        /// 本地文件变更个数
        /// </summary>
        public int LocalChanges { set; get; }

        /// <summary>
        /// 提交次数
        /// </summary>
        public int Commits { set; get; }

        /// <summary>
        /// 状态
        /// </summary>
        public RepoStatus Status { set; get; }

        /// <summary>
        /// 更新时状态
        /// </summary>
        [SQLite.Ignore]
        public RepoPullStatus PullStatus { set; get; }

        /// <summary>
        /// Git来源
        /// </summary>
        public RepoSource GitSource { set; get; }

        [Newtonsoft.Json.JsonIgnore()]
        public string PullMsg { set; get; }

        [Newtonsoft.Json.JsonIgnore()]
        public Action<string> OnPullMsg = null;

        public event PropertyChangedEventHandler PropertyChanged;

        [SQLite.Ignore]
        public string Folder { set; get; }

        /// <summary>
        /// 喜欢
        /// </summary>
        public bool IsFavorite { set; get; }
    }
}